package 力扣日常刷题.木22二月.第05天211;

import java.util.HashSet;

/**
 * @author 帅小伙
 * @date 2022/2/11
 * @description
 */
public class Demo41扑克牌中的顺子 {

    public boolean isStraight(int[] nums) {
        HashSet<Integer> set = new HashSet<>();
        int max = Integer.MIN_VALUE,min = Integer.MAX_VALUE;
        for (int num : nums) {
            if(num == 0) continue;
            if(set.contains(num)) return false;
            set.add(num);
            max = Math.max(max,num);
            min = Math.min(min,num);
        }
        return max - min < 5;
    }

}
